package com.feditory.product.provider.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import com.feditory.product.domain.Product;
import com.feditory.product.provider.ProductProvider;

public class ProductProviderImpl implements ProductProvider {
    @PersistenceContext
    private EntityManager em;

    @Override
    public Map<String, Product> retireveMaxLikeProductByWholesaleShopIds(List<String> wholeShopIds) {
        StringBuilder qlString = new StringBuilder(100);
        qlString.append("   SELECT MAX(p.likeCount), p  ");
        qlString.append("     FROM Product p ");
        qlString.append("    WHERE p.wholesaleShopId in (:wholesaleShopIds) ");
        qlString.append(" ORDER BY p.likeCount DESC ");
        qlString.append(" GROUP BY p.wholesaleShopId ");
        Query query = this.em.createQuery(qlString.toString());

        Map<String, Product> resultMap = new HashMap<String, Product>();
        for (String shopId : wholeShopIds) {

        }
        return null;
    }
    
}
